package com.itheima01.day09;

import java.util.Scanner;

/**
 * @author 刘全
 * @date 2021/7/10
 */
/*
需求：将（张三，23）（李四，24）（王五，25）封装为3个学生对象并存入数组
随后遍历数组，将学生信息输出在控制台
 */
public class StudentTest {
    public static void main(String[] args) {
        Student[] arr=new Student[3];
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < arr.length; i++) {
            System.out.println("请输入学生姓名:");
            String name=sc.next();
            System.out.println("请输入学生年龄:");
            int age = sc.nextInt();
            Student stu = new Student(name,age);
            arr[i] = stu;
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i].getName()+","+arr[i].getAge());
        }
    }
}
